package com.fafu.ioc.component;

import com.fafu.ioc.modal.UserInfo;
import org.apache.catalina.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class UserInfoComponent {
    @Bean
    public UserInfo userInfo(){
        return new UserInfo("zhangsan",18);
    }

    @Bean(name = {"zhangsan","豆英"})
    public UserInfo userInfo1(){
        return new UserInfo("zhangsan",18);
    }

    @Bean
    public String name(){
        return "666";
    }

    @Bean
    public String name1(){
        return "111";
    }


    //有两个的话, 名称要相同, 如果是其他名称比如name2, 会报错
//    @Primary
    @Bean
    public UserInfo userInfo2(String name){
        return new UserInfo(name,18);
    }
}
